﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.Web.Security;

namespace BeanOverflow.Models
{
    public class MemberProfile
    {
        [Key]
        public string UserId { get; set; }  //same as the id to log in; set when a user registers
        public string Position { get; set; }    //job position
        [DataType(DataType.MultilineText)]
        public string Bio { get; set; }     //biographical information of the user
        public int companyId { get; set; }  //used to associate user to a company
        public string role { get; set; }    
        [Column(TypeName = "image")]
        public Byte[] ImageData { get; set; }
        [HiddenInput(DisplayValue = false)]
        public string ImageMimeType { get; set; }
    }

    public class MemberProfileDBContext : DbContext
    {
        public DbSet<MemberProfile> MemberProfiles { get; set; }

        protected override bool ShouldValidateEntity(System.Data.Entity.Infrastructure.DbEntityEntry entityEntry)
        {
            // Required to prevent bug - http://stackoverflow.com/questions/5737733
            // http://erikej.blogspot.com/2011/04/saving-images-to-sql-server-compact.html
            if (entityEntry.Entity is MemberProfile)
            {
                return false;
            }
            return base.ShouldValidateEntity(entityEntry);
        }
    }
}